/******************************************************************************中
 * @brief: hpdf ext
 * @Author:   aple
 * @Date: 2022-12-14 18:06:21
 * @LastEditors: aple
 * @LastEditTime: 2023-02-05 09:24:00
 * @Verision: 1.0.0.0
 ******************************************************************************/
#ifndef __HPDF_EXT_H_
#define __HPDF_EXT_H_

#include "hpdf_conf.h"
#include "hpdf_utils.h"
#include "hpdf_pages.h"
#include "hpdf.h"
#include <stdint.h>
#include "dataproc.h"
#include "mytype.h"

// 自定义输出 - 需保证合法性 - 含参数列表
#define HPDF_CMD_NoExe 0x01
#define HPDF_CMD_End 0x02
#define HPDF_CMD_NoNum 0x10
#define HPDF_CMD_TFore 0x20
typedef struct
{
	const char *text;
	ii16 val;
	uu8 ip_n;
	// bit0-执行
	// bit1-结束
	// bit4-数据段跳过
	// bit5-0文本在后，1文本在前
	uu8 attr;
} hpdf_custom_par_type;

/*****************************************************************************
 * @brief   自定义输出
 *****************************************************************************/
void hpdf_custom(HPDF_Page page, const char *cmd);

/*****************************************************************************
 * @brief   自定义输出
 *****************************************************************************/
void hpdf_custom_with_par(
	HPDF_Page page,
	const char *cmd,
	ii32 par,
	uu8 ip_n);

void hpdf_custom_cfg(
	hpdf_custom_par_type *par,
	const char *text,
	ii16 val,
	uu8 ip_n,
	uu8 attr);

void hpdf_custom_exe(HPDF_Page page, hpdf_custom_par_type *par, ii8 max);

/*****************************************************************************
 * @brief   栈管理
 * @param   page       ：句柄
 * @return  执行状态
 *****************************************************************************/
uu32 hpdf_page_push(HPDF_Page page);
uu32 hpdf_page_pop(HPDF_Page page);

// 设置线宽，两位小数点
HPDF_EXPORT(HPDF_STATUS)
hpdf_page_set_line_width(
	HPDF_Page page,
	HPDF_INT32 line_width);

// 线端点节点模式 0平头 1圆头 2平头延申0.5w
HPDF_EXPORT(HPDF_STATUS)
hpdf_page_node_mode(
	HPDF_Page page,
	HPDF_INT8 line_join);

HPDF_EXPORT(HPDF_STATUS)
hpdf_page_endpoint_mode(
	HPDF_Page page,
	HPDF_INT8 mode);

// 设置线端点模式
#define hpdf_page_cap_mode HPDF_Page_SetLineCap
#define hpdf_page_stroke HPDF_Page_Stroke
#define hpdf_page_stroke_fill HPDF_Page_Fill
#define hpdf_page_get_height HPDF_Page_GetHeight
#define hpdf_page_get_width HPDF_Page_GetWidth
#define hpdf_page_set_height HPDF_Page_SetHeight
#define hpdf_page_set_width HPDF_Page_SetWidth

// 虚线模式
HPDF_EXPORT(HPDF_STATUS)
hpdf_page_dash_on(
	HPDF_Page page,
	ii16 on, ii16 off,
	uu8 ip_n);

HPDF_EXPORT(HPDF_STATUS)
hpdf_page_dash_off(HPDF_Page page);

// 设置画笔颜色-用于划线
HPDF_EXPORT(HPDF_STATUS)
hpdf_page_set_stroke_rgb(
	HPDF_Page page,
	HPDF_INT8 r,
	HPDF_INT8 g,
	HPDF_INT8 b);

// 设置路径当前位置坐标
HPDF_EXPORT(HPDF_STATUS)
hpdf_page_move_to(
	HPDF_Page page,
	HPDF_INT32 x,
	HPDF_INT32 y,
	HPDF_UINT8 ip_n);

// 画线路径 目标位置 并移动当前位置
HPDF_EXPORT(HPDF_STATUS)
hpdf_page_line_to(
	HPDF_Page page,
	HPDF_INT32 x,
	HPDF_INT32 y,
	HPDF_UINT8 ip_n);

// 设置路径当前位置坐标
HPDF_EXPORT(HPDF_STATUS)
hpdf_page_p1_move_to(
	HPDF_Page page,
	HPDF_INT32 x,
	HPDF_INT32 y);

// 画线路径 目标位置 并移动当前位置
HPDF_EXPORT(HPDF_STATUS)
hpdf_page_p1_line_to(
	HPDF_Page page,
	HPDF_INT32 x,
	HPDF_INT32 y);

HPDF_EXPORT(HPDF_STATUS)
hpdf_page_rectangle(
	HPDF_Page page,
	HPDF_INT32 x,
	HPDF_INT32 y,
	HPDF_INT32 width,
	HPDF_INT32 height,
	HPDF_UINT8 ip_n);

// 划曲线路径到目标位置 - 三次贝尔曲线 - 并移动当前位置到x3,y3
HPDF_EXPORT(HPDF_STATUS)
hpdf_page_curve123_to(
	HPDF_Page page,
	HPDF_INT32 x1,
	HPDF_INT32 y1,
	HPDF_INT32 x2,
	HPDF_INT32 y2,
	HPDF_INT32 x3,
	HPDF_INT32 y3,
	HPDF_UINT8 ip_n);

HPDF_EXPORT(HPDF_STATUS)
hpdf_page_curve23_to(
	HPDF_Page page,
	HPDF_INT32 x2,
	HPDF_INT32 y2,
	HPDF_INT32 x3,
	HPDF_INT32 y3,
	HPDF_UINT8 ip_n);

HPDF_EXPORT(HPDF_STATUS)
hpdf_page_curve13_to(
	HPDF_Page page,
	HPDF_INT32 x1,
	HPDF_INT32 y1,
	HPDF_INT32 x3,
	HPDF_INT32 y3,
	HPDF_UINT8 ip_n);

// 画圆路径
HPDF_EXPORT(HPDF_STATUS)
hpdf_page_cycle(
	HPDF_Page page,
	ii32 x,
	ii32 y,
	ii32 c,
	uu8 ip_n);

//****************************************************************
#define hpdf_page_end_text HPDF_Page_EndText
#define hpdf_page_begin_text HPDF_Page_BeginText

// 文本位置移动
HPDF_EXPORT(HPDF_STATUS)
hpdf_page_move_text_pos(
	HPDF_Page page,
	HPDF_INT32 x,
	HPDF_INT32 y);

HPDF_EXPORT(HPDF_STATUS)
hpdf_page_p1_move_text_pos(
	HPDF_Page page,
	HPDF_INT32 x,
	HPDF_INT32 y);

HPDF_EXPORT(HPDF_STATUS)
hpdf_page_show_text(
	HPDF_Page page,
	const char *text);

HPDF_EXPORT(HPDF_STATUS)
hpdf_page_show_text_check(HPDF_Page page);

HPDF_EXPORT(HPDF_STATUS)
hpdf_page_show_text_ascii(HPDF_Page page, const char *text);

HPDF_EXPORT(HPDF_STATUS)
hpdf_page_show_text_gbk(HPDF_Page page, const char *text);

// 设置填充颜色-用于文本
HPDF_EXPORT(HPDF_STATUS)
hpdf_page_set_text_rgb(
	HPDF_Page page,
	HPDF_INT8 r,
	HPDF_INT8 g,
	HPDF_INT8 b);

HPDF_EXPORT(HPDF_STATUS)
hpdf_page_set_font(
	HPDF_Page page,
	HPDF_Font font, uu8 size);

#ifdef __cplusplus
}
#endif

#endif /* __HPDF_EXT_H_ */
